export const mallRequest = (parmas) => {
    // 返回一个promise对象
    return new Promise((resolve, reject) => {
        let domain = 'https://shop.zyyexianlv.top/index.php';
        uni.request({
            url: domain + parmas.url,
            data: parmas.data,
            method: 'POST',
            header: {
                'content-type': 'application/json',
                Platform: 'H5',
                'Access-Token': uni.getStorageSync('mall_token')
            },
            success: (res) => {
                // 请求成功
                if (res.data.status == 200) {
                    resolve(res.data);
                }
                //token失效了
                else if (res.data.status == 401 && res.data.message == '没有找到用户信息') {
                    uni.removeStorage('mall_token');
                    resolve(-2);
                } else if (res.data.status == 500) {
                    resolve(res.data);
                } else {
                    resolve(-1);
                }
            },
            fail: (err) => {
                reject(err);
            }
        });
    });
};
